package com.example.oasystem.dao.daymanage;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.oasystem.entity.daymanage.AoaScheduleList;
import com.example.oasystem.entity.daymanage.EmpDTO;
import com.example.oasystem.entity.daymanage.mingzi;
import com.example.oasystem.entity.status.AoaStatusList;
import com.example.oasystem.entity.type.AoaTypeList;
import com.example.oasystem.entity.user.AoaUser;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface AoaScheduleListDao extends BaseMapper<AoaScheduleList> {
    @Select("SELECT COUNT(*) FROM aoa_schedule_list l WHERE l.user_id=#{id}")
    int myDay(@Param("id") int id);

    @Select("SELECT * from aoa_type_list")
    List<AoaTypeList> findProcessType();

    @Select("SELECT * from aoa_status_list")
    List<AoaStatusList> findProcessStatus();

    List<AoaScheduleList> getSche(@Param("id") int id, @Param("text") String text);
    List<mingzi> shar(@Param("rcid") int rcid);

    @Select("SELECT * FROM aoa_schedule_list l WHERE l.rc_id=#{rcid}")
    AoaScheduleList getUper(@Param("rcid") int rcid);

    //类型展示
    @Select("SELECT * FROM aoa_type_list l WHERE l.type_model='aoa_schedule_list' ")
    List<AoaTypeList> getType();
    //状态展示
    @Select("SELECT * FROM aoa_status_list l WHERE l.status_model='aoa_schedule_list' ")
    List<AoaStatusList> getStatu();
    //展示所有下级通讯录
    List<EmpDTO> getLowEmps(int userid);

    @Insert("INSERT INTO aoa_schedule_list (create_time,user_id,type_id,status_id,start_time,end_time,title,miaoshu,is_remind,isreminded) VALUES(#{createTime},#{userId},#{typeId},#{statusId},#{startTime},#{endTime},#{title},#{miaoshu},#{isRemind},#{isreminded})")
    @Options(useGeneratedKeys=true, keyProperty="rcId", keyColumn="rc_id")
    void InsertShe(AoaScheduleList scheduleList);

    List<AoaUser> getUserId(@Param("split") String[] split);
    int Insertuser2(@Param("id") int id, @Param("userid") Integer userid);
    int Insertuser(@Param("id") int id, @Param("userid") List<Integer> userid);
    //修改主表
    @Update("UPDATE aoa_schedule_list SET type_id=#{typeId},status_id=#{statusId},start_time=#{startTime},end_time=#{endTime},title=#{title},miaoshu=#{describe},is_remind=#{jizhu} WHERE rc_id=#{rcid}")
    int setShe(@Param("rcid") int rcid, @Param("typeId") int typeId, @Param("statusId") int statusId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("title") String title, @Param("describe") String describe, @Param("jizhu") int jizhu);

    @Delete("DELETE FROM aoa_schedule_user WHERE rcid=#{rcid}")
    int delUser(@Param("rcid") int rcid);
    @Delete("DELETE FROM aoa_schedule_list WHERE rc_id=#{rcid}")
    int delShe(@Param("rcid") int rcid);
}